package com.itany.corejava.code08_常用类.日期类;

import java.util.Date;

/**
 * @author 石小俊
 * 2024年07月22日 16:00
 */
public class Test02_常用方法 {

    public static void main(String[] args) {
        Date date = new Date();
        System.out.println(date.getYear() + 1900);
        System.out.println(date.getMonth() + 1);
        System.out.println(date.getDate());
        System.out.println(date.getDay());
        System.out.println((date.getYear() + 1900) + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日" + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds());

        System.out.println(date.getTime());

        //date = new Date(1721635412572L);
        //date.setTime(1721635412572L);
        //System.out.println((date.getYear() + 1900) + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日" + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds());

        Date date2 = new Date(1721635412572L);
        System.out.println("date是否在date2之前:" + date.before(date2));
        System.out.println("date是否在date2之后:" + date.after(date2));
        System.out.println(date.compareTo(date2));
    }

}
